#!perl -T

use Test::More tests => 5;

use Getopt::CommandLineExports qw(:ALL);

my @argv = qw(1 2 3 );
my @optSpec = qw(ONE=s TWO=s THREE=s FOUR=s);
my %args;
my %args_expected = (ONE => '1', TWO => '2', THREE => '3'); 
parseArgsByPosition( \@argv, \%args, @optSpec);
is_deeply(\%args, \%args_expected, "parseArgsByPosition - 3 scalars");

%args = (FOUR => undef);
%args_expected = (ONE => '1', TWO => '2', THREE => '3', FOUR => undef); 
parseArgsByPosition( \@argv, \%args, @optSpec);
is_deeply(\%args, \%args_expected, "parseArgsByPosition - 3 scalars - one default undefined");

%args = (FOUR => "Default");
%args_expected = (ONE => '1', TWO => '2', THREE => '3', FOUR => 'Default'); 
parseArgsByPosition( \@argv, \%args, @optSpec);
is_deeply(\%args, \%args_expected, "parseArgsByPosition - 3 scalars - one defined default");

@argv = ( "1,2,3,4", "5", "6");
%args = ();
%args_expected = (ONE => [1, 2, 3, 4]);
@optSpec = qw(ONE=s@);
parseArgsByPosition( \@argv, \%args, @optSpec);
is_deeply(\%args, \%args_expected, "parseArgsByPosition - One List");

@argv = ( "One=1,Two=2,Three=3,Four=4", "5", "6");
%args = ();
%args_expected = (ONE => [One => '1', Two => '2', Three => '3', Four => '4']);
@optSpec = qw(ONE=s%);
parseArgsByPosition( \@argv, \%args, @optSpec);
is_deeply(\%args, \%args_expected, "parseArgsByPosition - One List");
